package com.kuding.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.kuding.captcha.AliCaptchaComponent;
import com.kuding.props.AliyunCaptchaProperties;

@Configuration
@EnableConfigurationProperties({ AliyunCaptchaProperties.class })
@ConditionalOnProperty(value = "vinus.enable-aliyun-captcha", havingValue = "true")
public class AliyunCaptchaComponentConfig {

	@Autowired
	private AliyunCaptchaProperties aliyunCaptchaProperties;

	@Bean
	@ConditionalOnMissingBean
	public AliCaptchaComponent aliCapchaComponent() {
		AliCaptchaComponent aliCapchaComponent = new AliCaptchaComponent(aliyunCaptchaProperties);
		return aliCapchaComponent;
	}
}
